<?php
include_once("../service/CategoryService.php");
/**
 * @author Minh Luan
 * @copyright 2012
 */
if(isset($_GET['n'])){
    $cat_id = $_GET['n'];
    $categoryInfor = mysql_fetch_array(getCategory($cat_id));
    if(!hasChild($cat_id) && !hasProduct($cat_id)){
        //Delete Information
        deleteCategory($cat_id);
        //Delete Image
        if($categoryInfor["CAT_IMG_URL"] != ''){
            unlink("../images/cat/CAT_".$cat_id.".jpg");
        }
        
        echo "<script>location.href='../admin/category.php?msg=3'</script>";    
    }else{
        echo "<script>location.href='../admin/category.php?msg=4'</script>";
    }
}
?>